package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ShoppingCartMapper
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/6/25 15:09
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 新增购物车
     *
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 删除
     *
     * @param userId
     * @param dishId
     * @param setmealId
     */
    @Delete("delete from shopping_cart where user_id = #{userId} and (dish_id = #{dishId} or setmeal_id = #{setmealId})")
    void deleteByUserIdAndDishIdOrSetmealId(Long userId, Long dishId, Long setmealId);

    /**
     * 列表
     *
     * @param userId
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> listByUserId(Long userId);

    /**
     * 根据用户ID删除
     *
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    /**
     * 购物车列表
     *
     * @param userId
     * @return
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> selectListByUserId(Long userId);
}
